<?php

namespace App\Http\Controllers\View\User;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Services\User\GiRecordService;
use App\Facades\Utils\ValidateParameter;

class GiRecordController extends Controller
{
    public function index(){
        return view('pages.user.health_info.gi_record.list',[
                'giRecords' => GiRecordService::getRecordList(),
                'hasRecord' => GiRecordService::todayHasCreate()
            ]);
    }

    public function create(){
        return view('pages.user.health_info.gi_record.create');
    }

    public function update(Request $request){

    	$rules = [
            'id' => 'required|exists:gi_records,id'
        ];

        ValidateParameter::validate($request,$rules);

        $data = $request->all();

    	return view('pages.user.health_info.gi_record.update',[
    			'giRecord' => GiRecordService::getRecordById($data)
    		]);
    }
}
